package persistence;

import java.util.Date;
import java.util.Set;


/**
 * The Class Index which holds all the data structures for the data base and
 * perform actions on them.
 */
public interface Index {

	/**
	 * Instantiates a new index from persistence.
	 * @param indexURI the uri where index was saved
	 * @return an instance of index loaded from persistence
	 * @throws CorruptDataException if data read from the persistent index is not as expected.
	 */
	public Index loadIndex(final String indexURI) throws CorruptDataException;


	/**
	 * save index to persistence
	 */
	public void saveIndex();


	/**
	 * Gets the words by name.
	 *
	 * @param name the name
	 *
	 * @return the words by the word name
	 *
	 */
	public Long getWordsByName (final String name);

	/**
	 * Gets the message by its context.
	 *
	 * @param context the context
	 *
	 * @return the long
	 *

	 */
	public Long GetMessageByContext(final String context);

	/**
	 * Gets all the messages that the word appears in them by  word id.
	 *
	 * @param wordId the word id
	 *
	 * @return  Set<Long> the set of messages that the word appears in them
	 *

	 */
	public Set<Long> getWordInMessagesByWordId(final Long wordId);


	/**
	 * Gets the author id by user name.
	 *
	 * @param userName the user name
	 *
	 * @return the author id
	 *

	 */
	public Long getAuthorByUserName (final String userName);


	/**
	 * Gets the messages that were sent on a certain date by date.
	 *
	 * @param date -the date
	 *
	 * @return Set<Long> - the messages that were sent on a certain date
	 *

	 */
	public Set<Long> getMessagesByDate (final Date date);


	/**
	 * Gets the messages that were sent by a certain author- by author id.
	 *
	 * @param authorId the author id
	 *
	 * @return Set<Long> - the messages that were sent by a certain author
	 *

	 */
	public Set<Long> getMessagesByAuthorId(final Long authorId);

	/**
	 * Put word by name in the map.
	 *
	 * @param wordName the word name
	 * @param wordId the word id
	 */
	public void putWordByName(final String wordName,final Long wordId);


	/**
	 * Put message by context of message.
	 *
	 * @param context the context of message which is the message of a post
	 * @param messageId the message id
	 */
	public void putMessageByContext(final String context,final Long messageId);


	/**
	 * Put message in set of messages for a certain word.
	 * checks if already exists a set of messages for the word
	 * @param wordId the word id
	 * @param messageId the message id
	 */
	public void putMessageInSetOfMessagesForWord(final Long wordId,final Long messageId);


	/**
	 * Put author in map by user name.
	 *
	 * @param authorUserName the author user name
	 * @param authorId the author id
	 */
	public void putAuthorByUserName(final String authorUserName,final Long authorId);
	/**
	 * Put message in set of message for  a certain date.
	 * checks if already exists a set of messages for the date
	 * @param date the date
	 * @param messageId the message id
	 */
	public void putMessageInSetOfMessageForDate(final Date date,final Long messageId);
	/**
	 * Put message in set of message for author.
	 * checks if already exists a set of messages for the author id
	 * @param authorId the author id
	 * @param messageId the message id
	 */
	public void putMessageInSetOfMessageForAuthor(final Long authorId,final Long messageId);


	/**
	 * Contains word - checks if the map of words contains a certain word.
	 *
	 * @param wordName the word name
	 *
	 * @return true, if successful
	 */
	public boolean containsWord(final String wordName);



}
